<?php
    //ini_set('display_errors',1);
    include ("lib_db.php");
	include("function.php");
	include("config.php");
	if(!isset($_SESSION)){ session_start();}
if(!isset($_SESSION['user'])){
header('location:login.php');
exit();
}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xlmns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="author" content="lamtoan" />

	<title>ADMIN PANEL</title>
    <link type="image/x-icon" rel="shortcut icon" href="images/dnnicon.gif"/>
	<link href="css/style.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="js/clockp.js"></script>
	<script type="text/javascript" src="js/clockh.js"></script> 
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/ddaccordion.js"></script>
<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
</script>
<script type="text/javascript" src="js/jconfirmaction.jquery.js"></script>
<script type="text/javascript">
	
	$(document).ready(function() {
		$('.ask').jConfirmAction();
	});
	
</script>
</head>

<body>
<div class="wrapper">
	<div class="header"><?php include ("view/header.php");?></div>
	<div class="clear"></div>
	<div class="content">
		<div class="menu"><?php include("view/menu.php");?></div>
		<div class="center_content">
			<div class="left_content"> <?php include ("view/left_content.php");?></div>
			
			<div class="right_content">
				<h2>Danh sách sản phẩm</h2>
				<?php 
                $v=8;$k=0;$count=0;$pn=1;
                $sql="select * from book";
                $query=select_list($sql);if($query){$count=ceil(count($query)/$v);}//echo count($query);
                if(isset($_REQUEST['pn'])){$pn=$_REQUEST['pn'];$k=($pn-1)*$v;}
                $sql="select * from book limit $k,$v";
                $query=select_list($sql);
                if($query){echo category_product($query);}?>
				<a class="bt_green" href="insert_product.php"><span class="bt_green_lft"></span><strong>Thêm sản phẩm</strong><span class="bt_green_r"></span></a>
				<a class="bt_blue" href="#"><span class="bt_blue_lft"></span><strong>Xem tất cả sản phẩm</strong><span class="bt_blue_r"></span></a>
				<a class="bt_red" href="#"><span class="bt_red_lft"></span><strong>Xóa sản phẩm</strong><span class="bt_red_r"></span></a>
				
				<div class="items">
				<?php if($count>1){ if($pn==1){?>
					
					<span class="disabled"><< prev</span>
					<span class="current"><?php echo "1"; ?></span><?php }else{ ?>
					<a href="index.php?pn=<?php $j=$pn-1;echo $j; ?>"><< prev</a>
					<a href="index.php?pn=1"><?php echo "1";?></a><?php } ?>
					<?php for($i=2;$i<$count;$i++){ if($pn==$i){?>
					<span class="current"><?php echo "$i"; ?></span><?php }else{?>
					<a href="index.php?pn=<?php echo $i;?>"><?php echo $i;?></a>
					<?php }}?>
					<?php if($pn==$count){ ?>
					<span class="current"><?php echo "$count"; ?></span>
					<span class="disabled">next >></span<?php }else{ ?>
					<a href="index.php?pn=<?php echo $count?>"><?php echo "$count";?>
					<a href="index.php?pn=<?php $j=$pn+1;echo $j; ?>">next >></a><?php }?>
				<?php }?>
				</div>
			</div>
		</div>
	</div>
	<div class="clear"></div>
	<div class="footer">
		<div class="left_ft">
			<span>IN ADMIN PANEL | Powered by</span>
			<a href="http://indeziner.com">INDEZINER</a>
		</div>
		<div class="right_ft">
			<a href="http://indeziner.com"><img border="0" title="" alt="" src="images/indeziner_logo.gif"></a>
		</div>
	</div>
</div>
</body>
</html>
<?php } ?>